package org.nighthawkhosting.SC2Mapster;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TabHost;

public class SC2Mapster extends TabActivity {
	
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);

	    //Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Reusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, AnnouncementView.class);
	    
	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("announcement").setIndicator("Announcements",
	                      null)
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, ForumView.class);
	    spec = tabHost.newTabSpec("forum").setIndicator("Forums",
	    				null)
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, PMView.class);
	    spec = tabHost.newTabSpec("pm").setIndicator("PMs",
	    				null)
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, MapView.class);
	    spec = tabHost.newTabSpec("map").setIndicator("Maps",
	    				null)
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    tabHost.setCurrentTab(1);
	    
	    SharedPreferences settings = getSharedPreferences("SC2MAPSTER", 0);
	    if(settings.getInt("VERSION", 0) < 2) {
	    	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	    	builder.setMessage("New in Alpha 2\n\n*Added Maps Tab\nNote: Viewing Forums " +
	    			"is still not possible.");
	    	AlertDialog message = builder.create();
	    	message.setCanceledOnTouchOutside(true);
	    	message.show();
	    	
	    	SharedPreferences.Editor settingsEditor = settings.edit();
	    	settingsEditor.putInt("VERSION", 2);
	    	settingsEditor.commit();
	    }
	}

}
